# 示例：惰性判断的 map 和 filter
numbers = [1, 2, 3, 4, 5]

# map 返回一个迭代器，只有在需要时才会计算值
squared = map(lambda x: x**2, numbers)
print(next(squared))  # 输出: 1
print(next(squared))  # 输出: 4
print(next(squared))  # 输出: 9

# filter 返回一个迭代器，只有在需要时才会计算值
evens = filter(lambda x: x % 2 == 0, numbers)
print(next(evens))  # 输出: 2
print(next(evens))  # 输出: 4

flag = True


def pri_xxt():
    print("pri_xxt")


def pri_jdz():
    print("pri_jdz")


def lazy_func():
    if flag:
        lazy_func = pri_xxt
    else:
        lazy_func = pri_jdz
    print("lazy_func")


# print(lazy_func)

lazy_func()
lazy_func()
